using System;
using System.Collections.Generic;
using System.Text;

using My.IdlConverter.Core;

namespace My.IdlConverter.Com
{
    internal class ComRegistarTemplate
    {
        private static StringBuilder _templateString = new StringBuilder();

        static ComRegistarTemplate()
        {
            string tmplPathName = System.IO.Path.Combine(My.IdlConverter.Core.Cfg.Configuration.TemplatePath, "class_rgs.txt");
            string content;
            My.IdlConverter.Core.Util.IOHelper.ReadToEnd(tmplPathName,out content);
            _templateString.Append(content);
        }

        public static string Instantiate(string guid,string classTitle)
        {
            StringBuilder sb = new StringBuilder(_templateString.ToString());
            return sb.Replace(GlobalConst.ClassPattern, classTitle)
                      .Replace(GlobalConst.ClsidPattern, guid)
                      .Replace(GlobalConst.TypelibPattern,ComGuidCenter.Apply(Component.Name).ToString())
                      .Replace(GlobalConst.VersionTemplate,ComMyFitTemplateLibrary.DefaultVersion)
                      .Replace(GlobalConst.ComponentPattern,Component.Name)
                      .ToString();
        }
    }

}
